package com.deng.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class IndexController extends BaseController{
    @RequestMapping("")
    public String index(){
        //参数：分页信息，分类，用户，置顶，精选，排序
        IPage results= postService.paging(getPage(),null,null,null,null,"created");
        req.setAttribute("currentCategoryId",0);
        req.setAttribute("pageData", results);
        System.out.println(results.toString());
        return "index";
    }
    @RequestMapping("/search")
    public String search(String q){
        IPage pageData=searchService.search(getPage(),q);
        req.setAttribute("q",q);
        req.setAttribute("pageData",pageData);
        return "search";
    }
}


